package com.example.gyj.access;

import com.example.gyj.entity.User;

/**
 * 当前用户
 * @author Gao
 * @date 2018/11/4
 */
public class UserContext {

    /**
     * 保存用户，多线程的是保存的当前线程，线程安全
     */
    private static ThreadLocal<User> userHolder = new ThreadLocal<User>();

    public static void setUser(User user) {
        userHolder.set(user);
    }

    public static User getUser() {
        return userHolder.get();
    }
}
